home *** CD-ROM | disk | FTP | other *** search
/ Ray Dream Studio 5 / Ray Dream.iso / pc / DreamSDK / Windows / SAMPLES / ATMOS / FOG / FOGDLL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-11  |  2.9 KB  |  102 lines

  1. // Copyright (c)1995 Ray Dream, Inc. All Rights Reserved.
  2. /* $Id: FogDll.cpp 1.2 1996/07/23 17:32:58 Damien Exp $ */ 
  3.  
  4. ////////////////////////////////////////////////////////////////////////
  5. //   AtmospericShader Example : Atmos                                 //
  6. //--------------------------------------------------------------------//
  7. //   DLL Management                                                   //
  8. ////////////////////////////////////////////////////////////////////////   
  9.  
  10. #ifndef __FOGDLL__
  11. #include "FOGdll.h"
  12. #endif
  13.  
  14. #ifndef __COMFOG__
  15. #include "COMFOG.h"
  16. #endif
  17.  
  18. #ifndef __FOGFAC__
  19. #include "FOGFac.h"
  20. #endif
  21.  
  22. #ifndef __3DCOFAIL__
  23. #include "3DCoFail.h"
  24. #endif
  25.  
  26. //------------------------------------------------------------------------
  27. /*
  28.  * DllGetClassObject
  29.  *
  30.  * This function gives a IClassFactory with the appropriate CLSID.
  31.  * This DLL must be in the registration database as a InProcServer
  32.  * for the correct CLSID
  33.  *
  34.  * Parameters:
  35.  *  clsID           REFCLSID that identifies the class factory
  36.  *                  desired.  Since this parameter is passed this
  37.  *                  DLL can handle any number of objects simply
  38.  *                  by returning different class factories here
  39.  *                  for different CLSIDs.
  40.  *
  41.  *  riid            REFIID specifying the interface the caller wants
  42.  *                  on the class object, usually IID_ClassFactory.
  43.  *
  44.  *  ppv             LPVOID FAR* in which to return the interface
  45.  *                  pointer.
  46.  *
  47.  * Returns NOERROR on success, otherwise an error code
  48.  */
  49.  
  50. STDAPI DllGetClassObject(REFCLSID rclsid
  51.     , REFIID riid, LPVOID FAR* ppv) {
  52.   if (!IsEqualCLSID(rclsid, CLSID_Atmos))
  53.       return ResultFromScode(E_FAIL);
  54.  
  55.   //Check that we can provide the interface
  56.   if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
  57.       return ResultFromScode(E_NOINTERFACE);
  58.  
  59.   //Return our IClassFactory for the correct objects
  60.   if (IsEqualCLSID(rclsid,CLSID_Atmos))
  61.     *ppv=(LPVOID) new AtmosClassFactory();
  62.  
  63.   if (*ppv == NULL)
  64.       return ResultFromScode(E_OUTOFMEMORY);
  65.  
  66.   //AddRef the object through any interface we return
  67.   ((LPUNKNOWN)*ppv)->AddRef();
  68.  
  69.   return NOERROR;
  70.   }
  71.  
  72.  
  73. /*
  74.  * DllCanUnloadNow
  75.  *
  76.  *  Answers if the DLL can be unload from the memory
  77.  *
  78.  *  This function doesn't need any parameter
  79.  *
  80.  *  Returns TRUE if nothing is using us, FALSE otherwise.
  81.  */
  82.  
  83. STDAPI DllCanUnloadNow() {
  84.   SCODE   sc;
  85.  
  86.   //Our answer is whether there are any object or locks
  87.   sc=(0L==global_count_Obj && 0L==global_count_Lock) ? S_OK : S_FALSE;
  88.   return ResultFromScode(sc);
  89.   }
  90.  
  91. //------------------------------------------------------------------------
  92. //Count number of objects and number of locks.
  93. long       global_count_Obj  = 0;
  94. long       global_count_Lock = 0;
  95.  
  96. STDAPI DllInitRDCom(IShUtilities* shellUtilities) {
  97.     InitCoFailure(shellUtilities);
  98.     return S_OK;
  99.     }
  100.  
  101.  
  102.